/**
 * 应用层
 *  1. 实例化一个esp8266对象
 *  2. 调用MqttPublish，发布一条消息上EMQX
 */
var esp8266 = require("./esp8266.js");
var log = require("./nlog.js")

var espDev = esp8266();

espDev.event.on("ESP8266_INIT_FINISH", function() {
    espDev.MqttPublish("Hello world!");
    espDev.event.on("MQTT_MSG", function(mqttMsg) {
        log.d(mqttMsg);
        espDev.MqttPublish(mqttMsg);
    });
});